import cv2
import numpy as np

if __name__ == "__main__":
    path = 'image2.jpg'
    image_np = cv2.imread(path)
    image_np_b = np.zeros((image_np.shape[0], image_np.shape[1], 3), dtype=np.uint8)
    image_np_g = np.zeros((image_np.shape[0], image_np.shape[1], 3), dtype=np.uint8)
    image_np_r = np.zeros((image_np.shape[0], image_np.shape[1], 3), dtype=np.uint8)
    b, g, r = cv2.split(image_np)        # 拆分
    # print(b)
    print(b.shape)
    image_np_b[:, :, 0] = b
    # print(image_np_b)

    image_np_g[:, :, 1] = g
    # print(image_np_g)

    image_np_r[:, :, 2] = r
    # print(image_np_r)

    cv2.imshow('image_np_b', image_np_b)
    cv2.imshow('image_np_g', image_np_g)
    cv2.imshow('image_np_r', image_np_r)
    cv2.waitKey(0)